Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute mutability of closure captures #37

Closed
wants to merge 3 commits into from
Closed

Conversation

arora-aman
Copy link
Member

@arora-aman arora-aman commented Dec 13, 2020

When capture_disjoint_fields is not enabled, checking if the root variable
binding is mutable would suffice.

However, with the feature enabled, the captured place might be mutable
because it dereferences a mutable reference.

This PR computes the mutability of each capture after capture analysis
in rustc_typeck. We store this in ty::CapturedPlace and then use
ty::CapturedPlace::mutability in mir_build and borrow_check.


This change is Reviewable

When `capture_disjoint_fields` is not enabled, checking if the root variable
binding is mutable would suffice.

However with the feature enabled, the captured place might be mutable
because it dereferences a mutable reference.

This PR computes the mutability of each capture after capture analysis
in rustc_typeck. We store this in `ty::CapturedPlace` and then use
`ty::CapturedPlace::mutability` in mir_build and borrow_check.
@arora-aman
Copy link
Member Author

rust-lang#80092

@arora-aman arora-aman closed this Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant